/**
 * Copyright (c) 2006-2013 Las Venturas Mineground
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 */

package org.mineground.events;

import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerLoginEvent;

/**
 * The Event Listener follows all relevant Bukkit events, and then dispatches them through our
 * own, simpler event dispatcher. We listen to all required events at a high priority, and will
 * ignore whether it has been cancelled by a previous event handler or not.
 * 
 * Events in Bukkit are being invoked in reverse order of priority. High priority events take
 * precedence over normal priority events by being called *after* them, even if the event was
 * cancelled by an event handler of lower priority. In Mineground we turn this around, because
 * cancelling an event means further handlers will not be called anymore.
 */
public class BukkitEventListener implements Listener {
    @EventHandler(priority = EventPriority.HIGH)
    public void onPlayerLogin(PlayerLoginEvent event) {
        EventDispatcher.DispatchEvent(event);
    }
    
    @EventHandler(priority = EventPriority.HIGH)
    public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
        EventDispatcher.DispatchEvent(event);
    }
}
